//
//  BaseViewController.swift
//  Status
//
//  Created by 花轮 on 15/5/10.
//  Copyright (c) 2015年 花轮. All rights reserved.
//

import UIKit

class BaseViewController: UITableViewController, VisitorLoginViewDelegate {

        var userLogin = sharedUserAccount != nil
    
        var visitorView: VisitorLoginView?

    override func loadView()
    {
        if userLogin
        {
            super.loadView()
            return
        }
        
        visitorView = NSBundle.mainBundle().loadNibNamed("VisitorLoginView", owner: nil, options: nil).last as? VisitorLoginView
        view = visitorView
        
        visitorView?.delegate  = self
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewRegisterBtnDidCilck:")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewLoginBtnDidCilck:")
    }
    
    
    func visitorViewLoginBtnDidCilck(_: VisitorLoginView)
    {
        let sb = UIStoryboard(name: "OAuth", bundle: nil)
        presentViewController(sb.instantiateInitialViewController() as! UIViewController, animated: true, completion: nil)
    }
    func visitorViewRegisterBtnDidCilck(_: VisitorLoginView) {
        UIActionSheet(title: "加入我们？", delegate: nil, cancelButtonTitle: "取消", destructiveButtonTitle: "确定").showInView(self.view)
    }
}
